/**
 * Created by 13576 on 2018/1/3.
 */
import config from 'config'
import httpFetch from 'share/httpFetch'

export default {
  /**
   * 保存差旅申请单提醒
   * @param params = {
     code:"TravelApplicationNoticeTask"
     companyOID:"5ea88443-d99d-4f2e-8aa4-c4d73dc9c67b"
     enabledFlag:true
     hour:3
     params:"{"remindDay":12,"title":"213123","content":"3123fdf","formOIDs":["286b895d-b1b3-4cf9-8e4d-44e9858b2035"]}"
    }
   */
  newBeepTimer(params){
    return httpFetch.post(`${config.baseUrl}/api/taskConfig`,params)
  },

  /**
   * 保存差旅申请单提醒
   * @param params = {
   * id:
     code:"TravelApplicationNoticeTask"
     companyOID:"5ea88443-d99d-4f2e-8aa4-c4d73dc9c67b"
     enabledFlag:true
     hour:3
     params:"{"remindDay":12,"title":"213123","content":"3123fdf","formOIDs":["286b895d-b1b3-4cf9-8e4d-44e9858b2035"]}"
    }
   */
  updateBeepTimer(params){
    return httpFetch.put(`${config.baseUrl}/api/taskConfig`,params)
  },

  /**
   * 根据OId查询申请单名称
   * @param params =[]
   */
  getByOIDs(params){
    return httpFetch.post(`${config.baseUrl}/api/custom/forms/getByOIDs`,params)
  },

  /**
   * 根据查询提醒单据
   * @param params ={
   *    companyOID:""
   * }
   * LoanApplicationNoticeTask（借款申请单提醒）
   * TravelApplicationNoticeTask（差旅申请单提醒）
   */
  getFormsByOIDs(params){
    return httpFetch.post(`${config.baseUrl}/api/taskConfig/queryByExample`,params)
  },

  /**
   * 删除差旅申请单提醒
   * @param params =[]
   */
    deleteTraveApprove(params){
      return httpFetch.delete(`${config.baseUrl}/api/taskConfig`,params)
    },

    /**
    * 查询当前租户已开通的所有商务卡类别
    * */
    getBusinessCardType(){
      return httpFetch.get(`${config.baseUrl}/api/tenant/bankcard/status`)
    },

  /**
   * 根据商务卡code获取商务卡名称
   * @param params =[
   *  codes = []
   * ]
   * */
  getBusinessCardTypeNameByCode(params){
    return httpFetch.get(`${config.baseUrl}/api/bankcard/type/by/codes`)
  },

  //获取该公司或被分配的所有启用中的差旅单
  getAllTraverApprove(companyOID){
    let params = {
      companyOID,
      page: 0,
      size: 1000,
      formTypeList: [2001] //2001-差旅申请单
    };
    return httpFetch.get(`${config.baseUrl}/api/custom/forms/loan/reference`, params)
  },

  //查询所有的借款申请单
  getAllLoanApprove(){
    return httpFetch.get(`${config.baseUrl}/api/custom/forms/company/loan/application/all`)
  },

  //获取费用包含标签
  getInvoiceLabels(){
    return httpFetch.get(`${config.baseUrl}/api/expense/labels?labelCategory=2`)
  },

  // 获取所有单据类型
  getAllInvoiceType(companyOid){
    let params = { companyOid };
    return httpFetch.get(`${config.baseUrl}/api/custom/forms/loan/application`, params)
  },

  getAllLoanType(setOfBookId){
    return httpFetch.get(`${config.baseUrl}/payment/api/cash/transaction/classes/queryBySetOfBookId/${setOfBookId}`)
  },

  //获取该公司或被分配的所有启用中的报销单
  getExpenseList(companyOID) {
    let params = {
      companyOID,
      page: 0,
      size: 1000,
      formTypeList: [3001, 3002, 3003] //3001-日常报销单，3002-差旅报销，3003-费用报销
    };
    return httpFetch.get(`${config.baseUrl}/api/custom/forms/loan/reference`, params)
  },

  // 获取信用规则
  getHonestRule(params) {
    return httpFetch.get(`/api/credit/task/condition/list`, params);
  },

  // 信用规则保存
  saveHonestInfo(params) {
    return httpFetch.put(`/api/credit/task/condition`, params);
  },

  // 提醒规则列表所配置的信用
  getHonestList(id) {
    return httpFetch.get(`/api/credit/${id}/task/condition`)
  }
}
